package com.LeeCode;

/**
 * 统计符合条件长度为 3 的子数组数目
 */

public class Code3392 {
    public static void main(String[] args) {
        int[] nums = {-1, -4, -1, 4};
        System.out.println(new Code3392().countSubarrays(nums));
    }

    public int countSubarrays(int[] nums) {
        int ans = 0;
        for (int i = 1; i < nums.length - 1; i++) {
            if (nums[i] == (nums[i - 1] + nums[i + 1]) * 2) {
                ans++;
            }
        }
        return ans;
    }
}
